import request from './request'
async function handleRowClick(row, column, cell) {
    const el = cell.querySelector('.icon-download')
        // 判断点击的是下载按钮
    if (el) {
        // 请求该歌曲的url
        let res = await this.$request('/song/url', { id: row.id })
        if (res.data.data[0].url == null) {
            this.$message.warning('暂时无法获取该资源哦!')
            return
        }
        // 匹配资源的域名
        let url = res.data.data[0].url.match(/\http.*?\.net/)
            // 匹配域名名称，并匹配对应的代理
        let serve = url[0].match(/http:\/(\S*).music/)[1]
        if (serve != '/m7' && serve != '/m701' && serve != '/m8' && serve != '/m801') {
            // 没有对应的代理
            this.$message.error('匹配不到对应的代理,下载失败!')
            return
        }
        // 截取后面的参数
        let params = res.data.data[0].url.slice(url[0].length)
            // console.log(url[0], serve, params);
        let downloadMusicInfo = {
            url: serve + params,
            name: row.name + ' - ' + row.ar[0].name + '.' + res.data.data[0].type.toLowerCase()
        }
        console.log(downloadMusicInfo)
        this.$store.commit('updateDownloadMusicInfo', downloadMusicInfo)
    }
}